home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / vgl20.zip / FONTDEMO.C < prev    next >
Text File  |  1993-05-15  |  3KB  |  128 lines

  1. /*****************************************************************************
  2.  FONTDEMO.C
  3.  
  4.  Simple program that displays each font it finds in the FONTS subdirectory
  5.  on the screen.  Press any key to go to the next font.  After the last font
  6.  is displayed, it'll exit to DOS.
  7.  
  8.  Each font that is found is displayed in normal, bold, underline, shadow,
  9.  and italics modes.
  10.  
  11.  Sorry there are so few fonts, but it took me about 20-30 minutes per font
  12.  to "create" them.
  13.  
  14.  By the way, the DIGITAL font is so big that it wraps and overlaps in this
  15.  demo.  You can still see what it looks like though.
  16.  
  17.  Although the fonts are in their own subdirectory, and this demo expects to
  18.  find them there, you don't *have* to have them there in your own programs.
  19.  Neither do they *have* to have a .FON extension.  You can rename them to be
  20.  anything you want.
  21.  
  22.  If you can supply me a 320x200x256 picture containing the letters of a
  23.  particular font, I can use my quick'n'dirty tools to create a new .FON
  24.  file for you.  I don't mind doing this as it adds to the VGL font list.
  25.  It must have a black (color 0) background.  The characters can be any color.
  26.  
  27.  Mark
  28.  morley@camosun.bc.ca
  29. *****************************************************************************/
  30.  
  31. #include <dir.h>
  32. #include "vgl.h"
  33.  
  34. void main()
  35. {
  36.    int          k;
  37.    int          x, y;
  38.    struct ffblk fb;
  39.    int          n = 0;
  40.  
  41.    /* Go into the FONTS subdirectory */
  42.    if( chdir( "fonts" ) )
  43.    {
  44.       printf( "No FONTS subdirectory!\n" );
  45.       return;
  46.    }
  47.  
  48.    /* Enter mode 13h */
  49.    vglInit();
  50.  
  51.    /* Set text color to WHITE */
  52.    vglTextColor( 15 );
  53.  
  54.    /* Set shadow color to GREEN */
  55.    vglShadowColor( 2 );
  56.  
  57.    /* Set underline color to RED */
  58.    vglUnderlineColor( 4 );
  59.  
  60.    /* Find the first font */
  61.    if( !findfirst( "*.fon", &fb, 0 ) )
  62.    {
  63.       do
  64.       {
  65.          n++;
  66.  
  67.          /* Clear to a black screen */
  68.          vglClear( 0 );
  69.  
  70.          /* Load in a font */
  71.          vglLoadFont( fb.ff_name );
  72.  
  73.          /* Turn off all the special settings */
  74.          vglBoldOff();
  75.          vglItalicsOff();
  76.          vglShadowOff();
  77.          vglUnderlineOff();
  78.  
  79.          /* Got to the top left corner of the screen */
  80.          vglGotoXY( 0, 0 );
  81.  
  82.          /* Display the font's file name */
  83.          vglPuts( fb.ff_name );
  84.  
  85.          /* New line */
  86.          vglPuts( "\r\n\n" );
  87.  
  88.          /* Bolded sample */
  89.          vglBoldOn();
  90.          vglPuts( "Bolded" );
  91.          vglBoldOff();
  92.  
  93.          /* Underlined sample */
  94.          vglGotoXY( 160, vglGetY() );
  95.          vglUnderlineOn( 2 );
  96.          vglPuts( "Underlined\r\n" );
  97.          vglUnderlineOff();
  98.  
  99.          /* Shadowed sample (Shadow depth = 1 pixel) */
  100.          vglShadowOn( 1 );
  101.          vglPuts( "Shadowed" );
  102.          vglShadowOff();
  103.  
  104.          /* Italics sample */
  105.          vglGotoXY( 160, vglGetY() );
  106.          vglItalicsOn();
  107.          vglPuts( "Italics\r\n" );
  108.          vglItalicsOff();
  109.  
  110.          /* Miscellaneous characters */
  111.          vglPuts( "ABCDabcd123!@#$" );
  112.  
  113.          /* Get a keypress */
  114.          getch();
  115.  
  116.          /* Find the next font */
  117.       } while( !findnext( &fb ) );
  118.    }
  119.  
  120.    /* Backup to the parent directory */
  121.    chdir( ".." );
  122.  
  123.    /* Return to text mode */
  124.    vglTerm();
  125.  
  126.    printf( "%d fonts\n", n );
  127. }
  128.